//var baseUrl = 'http://192.168.110.108:8080';
var baseUrl = 'http://stl.bobzyh.top/api';

var pageInfo = {
	page: 1,
	limit: 10,
};

loadCourse();

// 列表模板
var template = '\
				<li>\
					<div class="info">\
						<img class="photo" src="">\
						<div class="course">瑜伽</div>\
						<div class="coach">小小</div>\
						<div class="time">2024-05-31 18:30:00</div>\
					</div>\
					<div class="reserve">\
						<a class="btn-reserve">立即预约</a>\
					</div>\
				</li>';
// 加载课程
function loadCourse(){	
	// ajax
	$.ajax({
		url: baseUrl + '/course',
		data: pageInfo,
		dataType: 'json',
		success(result){
			$('.list').empty();
			$.each(result.data.list, function(index, item){
				var dom = $(template);
				dom.find('.photo').attr('src', baseUrl + item.photo);
				dom.find('.course').text(item.name);
				dom.find('.coach').text(item.coach.name);
				dom.find('.time').text(item.time.substring(5, 16));
				$('.list').append(dom);
			});
		}
	});
}